import datetime

from sqlalchemy import Column, Integer, String, Float, DateTime, UniqueConstraint, ForeignKey

from QualityInspectionViolation.DbInit.mysqlDb import Base


class SoundRecording(Base):
    __tablename__ = 'sound_recording'
    id = Column(Integer, primary_key=True)
    recordingAddress = Column(String(100))
    callRecordId = Column(Integer)
    duration = Column(Integer)
    createdAt = Column(DateTime, default=datetime.datetime.now)
    updatedAt = Column(DateTime, default=datetime.datetime.now)

    def querySoundRecording(self, soundRecordingId, session):
        soundRecording = session.query(SoundRecording).\
            filter(SoundRecording.id == soundRecordingId).first()
        return soundRecording

